set.seed(2) # R-side repeatability (need to set JAGS RNG seed separately)
library(tidyverse)
library(tidybayes)
library(ggplot2)
library(ggExtra)
library(kableExtra)
library(tidyr)
library(readxl)
library(lubridate)
library(sf)
library(raster)
library(amt)
library(purrr)
library(runjags)
select<-dplyr::select
crs_utm18n <- "EPSG:26918" # UTM zone 18N, https://epsg.io/32618
# fish metadata recorded after tagging and release
fishids <- read_excel("BowfinInventory_gj.xls") %>%
mutate(id=as.character(FishID)) %>%
filter(is.na(Omit)) #filter out dead fish
#Load pre-conditioned telemetry data.
dat1 <- read_csv("bowfin_data.csv") %>%
right_join(fishids) %>% #right join to carry through dead fish filter
mutate(Sex=factor(Sex), Year=factor(Year), ReleaseSite=factor(ReleaseSite),
Zdoy=scale(.$endDOY)[,1])
# extract all point location fish observations
# projected in CRS: NAD83 / UTM zone 18N
fishobs <- dat1 %>%
select(FishID, Year, DOY=endDOY, DateTime, Latitude, Longitude) %>%
st_as_sf(coords = c("Longitude", "Latitude"), crs=4326) %>%
st_transform(crs=crs_utm18n)
# sf object of initial capture locations for each fish
caploc <- fishids %>%
mutate(x=if_else(ReleaseSite=="Bradburys", -76.11321, -75.92999),
y=if_else(ReleaseSite=="Bradburys", 43.25366, 43.17359)) %>%
st_as_sf(coords=c("x", "y"), crs=4326) %>%
st_transform(crs=crs_utm18n) %>%
mutate(Year=year(ReleaseDate), DOY=yday(ReleaseDate),
DateTime=ReleaseDate) %>%
select(FishID, Year, DOY, DateTime)
# sf formatted point for Bradburys, projected in UTM 18N
bigbayloc <- st_drop_geometry(caploc) %>%
mutate(DOY=1, x=-76.11321, y=43.25366) %>%
st_as_sf(coords=c("x", "y"), crs=4326) %>% st_transform(crs=crs_utm18n)
# add initial capture location for NSD reference location (comment out to omit)
# fishobs <- rbind(caploc, fishobs)
# define NSD reference location as Big Bay (comment out to omit)
fishobs <- rbind(bigbayloc, fishobs)
dat <- left_join(fishobs, fishids) %>%
mutate(x_=st_coordinates(.)[,1]/1000, y_=st_coordinates(.)[,2]/1000,
t_=DateTime) %>%
st_drop_geometry() %>% as_tibble() %>%
select(x_, y_, t_, sex=Sex, tl=TLmm, kg=Wkg, id=FishID, rel=ReleaseSite,
t_rel=ReleaseDate, surgeon=Surgeon, year=Year)
dat0 <- make_track(dat, x_, y_, t_, id, sex, tl, kg, rel, crs=crs_utm18n) %>%
nest(data =c(x_, y_, t_))
Supporting spatial data
# Oneida Lake boundary from NHD v2.1
olb <- sf::st_read(dsn="supporting", layer="OneidaLake_utm18n")
## Reading layer `OneidaLake_utm18n' from data source
## `C:\Users\gj93\Box\Bowfin_telemetry\bowfin_analysis_mobile\bowfin_HR_SignerWorkflow_220709\manuscript_version\supporting'
## using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 14 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 407400 ymin: 4777457 xmax: 440730.1 ymax: 4789914
## Projected CRS: NAD83 / UTM zone 18N
lrw <- raster("supporting/lrwindicator")
lrw_df <- as.data.frame(lrw*!is.na(lrw), xy=TRUE) %>%
mutate(value=ifelse(layer==1, 1, NA))
Run Bayesian change-point analysis.
library(mcp)
# helper objects/dimensions
pview <- c(407400.0, 4777456.9, 427398.1, 4789913.8 )
maxNSD <- max(dist(dat[,c("x_", "y_")]))^2
#data sets
# meta data for each fish
mcp_meta <- lapply(dat0$id, function(x) { filter(dat0, id==x) })
names(mcp_meta)<-dat0$id
# telemetry object from package `amt`
mcp_telem <- lapply(mcp_meta, function(a) as_telemetry(a$data[[1]]))
#If interested, check out the semivariograms
#fit_svf <- lapply(mcp_telem, ctmm::variogram)
#p4 <- ggplotify::as.ggplot(~plot(fit_svf, level=c(0.5,0.95)))
# spatial track data in sf POINTS format, converted back to meters UTM
mcp_sf1 <- lapply(mcp_meta, function(a) {
a$data[[1]] %>% mutate(nsd=nsd(.), year=factor(year(t_)),
doy=yday(t_), dec.year=decimal_date(t_),
x_=x_*1000, y_=y_*1000) %>%
filter(doy>1) %>% #exclude dummy initial location prior to analysis
as_sf_points()
})
# spatial track data in sf LINES format, converted back to meters UTM
mcp_sf_lines <- lapply(mcp_meta, function(a) {
a$data[[1]] %>% mutate(nsd=nsd(.), year=factor(year(t_)),
doy=yday(t_), dec.year=decimal_date(t_),
x_=x_*1000, y_=y_*1000) %>%
filter(doy>1) %>% #exclude dummy initial location prior to analysis
as_sf_lines()
})
#get rid of origin only "tracks" (when origin included, run anyway, no change)
mcp_sf <- mcp_sf1[which(sapply(mcp_sf1, nrow)>1)]
#Concatenate mcp_sf to one data table
dat_sf <- bind_rows (mcp_sf, .id="id") %>%
dplyr::mutate(x_km = sf::st_coordinates(.)[,1]/1000,
y_km = sf::st_coordinates(.)[,2]/1000,
id=as.numeric(id)) %>%
left_join(fishids, by=join_by(id==FishID))
Function to initialize chains. This links the JAGS RNG to the seed set in R, for repeatability.
inits0 <- function(chains=1){
inits.out <- list()
for (c in 1:chains){
inits.i <- list()
inits.i$.RNG.name = "base::Wichmann-Hill"
inits.i$.RNG.seed = runif(1, 1, 1e3)
inits.out[[c]] <- inits.i
}
return(inits.out)
}
adapt=200000
iter=50000
set.seed(2)
system.time(
mcp_models <- lapply(1:length(mcp_sf), function(i) {
#mcp_models <- lapply(1:1, function(i) { #
x <- mcp_sf[[i]]
print(paste(i, " out of ", length(mcp_sf), "; ", Sys.time(), sep=""))
n <- nrow(x)
e <- simpleError("Fail")
# Fit four models: null and 3 cp models
# null model: 1 mean, 1 variance
fit0 <- tryCatch(
mcp(model=list(nsd~1),
prior=list(int_1="dnorm(0, 1000) T(0,)"),
inits=inits0(chains=3),
data=x, par_x="dec.year", adapt=adapt, iter=iter),
error=function(e) e)
# 1 location, 2 variances, 1 change point
fit1 <- tryCatch(
mcp(model=list(nsd~1,
(1|year)~1 + sigma(1)),
prior=list(int_1="dnorm(0, 1000) T(0,)",
cp_1="dnorm(180, 20) T(0, 200)",
cp_1_sd="dnorm(0, 20) T(0,)",
int_2="int_1"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter, sample="both"),
error=function(e) e)
# 2 locations, 2 variances, 1 change point
fit2 <- tryCatch(
mcp(model=list(nsd~1,
(1|year)~1 + sigma(1)),
prior=list(int_1="dnorm(0, 1000) T(0,)",
int_2="dnorm(0, 1000) T(0,)",
cp_1="dnorm(180, 20) T(0, 200)",
cp_1_sd="dnorm(0, 20) T(0,)"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter, sample="both"),
error=function(e) e)
fitlist <- list(fit0=fit0, fit1=fit1, fit2=fit2)
if (nrow(x)>=12){ #the smallest that should work on our data sets
# 3 locations, 3 variances, and 2 change points
fit3 <- tryCatch(
mcp(model=list(nsd~1,
(1|year)~1 + sigma(1),
(1|year)~1),
prior=list(int_1="dnorm(0, 1000) T(0,)",
int_2="dnorm(0, 1000) T(0,)",
cp_1="dnorm(180, 20) T(0, 200)",
cp_2="dnorm(250, 20) T(200, 365)",
cp_1_sd="dnorm(0, 20) T(0,)",
cp_2_sd="dnorm(0, 20) T(0,)",
int_3="int_1"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter, sample="both"),
error=function(e) e)
fitlist$fit3 <- fit3
}
return(fitlist)
})
)
## [1] "1 out of 36; 2024-03-04 12:31:10.687323"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 24
## Unobserved stochastic nodes: 2
## Total graph size: 138
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 24
## Unobserved stochastic nodes: 8
## Total graph size: 479
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 32
## Total graph size: 479
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 24
## Unobserved stochastic nodes: 9
## Total graph size: 480
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 33
## Total graph size: 480
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 24
## Unobserved stochastic nodes: 14
## Total graph size: 615
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 38
## Total graph size: 615
##
## Initializing model
##
## [1] "2 out of 36; 2024-03-04 12:35:09.906667"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 55
## Unobserved stochastic nodes: 2
## Total graph size: 293
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 55
## Unobserved stochastic nodes: 8
## Total graph size: 1073
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 63
## Total graph size: 1073
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 55
## Unobserved stochastic nodes: 9
## Total graph size: 1074
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 64
## Total graph size: 1074
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 55
## Unobserved stochastic nodes: 14
## Total graph size: 1369
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 69
## Total graph size: 1369
##
## Initializing model
##
## [1] "3 out of 36; 2024-03-04 12:42:55.328695"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 2
## Total graph size: 198
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 8
## Total graph size: 714
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 44
## Total graph size: 714
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 9
## Total graph size: 715
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 715
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 14
## Total graph size: 915
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 50
## Total graph size: 915
##
## Initializing model
##
## [1] "4 out of 36; 2024-03-04 12:48:37.699709"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 20
## Unobserved stochastic nodes: 2
## Total graph size: 118
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 20
## Unobserved stochastic nodes: 8
## Total graph size: 418
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 28
## Total graph size: 418
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 20
## Unobserved stochastic nodes: 9
## Total graph size: 419
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 29
## Total graph size: 419
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 20
## Unobserved stochastic nodes: 14
## Total graph size: 539
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 34
## Total graph size: 539
##
## Initializing model
##
## [1] "5 out of 36; 2024-03-04 12:52:09.722524"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 7
## Unobserved stochastic nodes: 2
## Total graph size: 53
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 7
## Unobserved stochastic nodes: 7
## Total graph size: 168
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 14
## Total graph size: 168
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 7
## Unobserved stochastic nodes: 8
## Total graph size: 169
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 15
## Total graph size: 169
##
## Initializing model
##
## [1] "6 out of 36; 2024-03-04 12:52:50.820879"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 5
## Unobserved stochastic nodes: 2
## Total graph size: 43
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 5
## Unobserved stochastic nodes: 7
## Total graph size: 130
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 12
## Total graph size: 130
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 5
## Unobserved stochastic nodes: 8
## Total graph size: 131
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 13
## Total graph size: 131
##
## Initializing model
##
## [1] "7 out of 36; 2024-03-04 12:53:25.379093"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 27
## Unobserved stochastic nodes: 2
## Total graph size: 153
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 27
## Unobserved stochastic nodes: 8
## Total graph size: 547
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 35
## Total graph size: 547
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 27
## Unobserved stochastic nodes: 9
## Total graph size: 548
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 36
## Total graph size: 548
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 27
## Unobserved stochastic nodes: 14
## Total graph size: 703
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 41
## Total graph size: 703
##
## Initializing model
##
## [1] "8 out of 36; 2024-03-04 12:57:51.465446"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 2
## Total graph size: 93
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 8
## Total graph size: 306
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 23
## Total graph size: 306
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 9
## Total graph size: 307
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 24
## Total graph size: 307
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 14
## Total graph size: 397
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 29
## Total graph size: 397
##
## Initializing model
##
## [1] "9 out of 36; 2024-03-04 13:00:40.773213"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 2
## Total graph size: 93
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 8
## Total graph size: 323
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 23
## Total graph size: 323
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 9
## Total graph size: 324
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 24
## Total graph size: 324
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 15
## Unobserved stochastic nodes: 14
## Total graph size: 419
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 29
## Total graph size: 419
##
## Initializing model
##
## [1] "10 out of 36; 2024-03-04 13:03:25.994766"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 2
## Total graph size: 233
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 8
## Total graph size: 851
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 51
## Total graph size: 851
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 9
## Total graph size: 852
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 52
## Total graph size: 852
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 14
## Total graph size: 1087
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 57
## Total graph size: 1087
##
## Initializing model
##
## [1] "11 out of 36; 2024-03-04 13:09:45.421337"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 2
## Total graph size: 233
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 8
## Total graph size: 845
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 51
## Total graph size: 845
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 9
## Total graph size: 846
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 52
## Total graph size: 846
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 43
## Unobserved stochastic nodes: 14
## Total graph size: 1081
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 57
## Total graph size: 1081
##
## Initializing model
##
## [1] "12 out of 36; 2024-03-04 13:16:06.998313"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 2
## Total graph size: 283
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 8
## Total graph size: 1029
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 61
## Total graph size: 1029
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 9
## Total graph size: 1030
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 62
## Total graph size: 1030
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 14
## Total graph size: 1315
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 67
## Total graph size: 1315
##
## Initializing model
##
## [1] "13 out of 36; 2024-03-04 13:23:36.268877"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 2
## Total graph size: 183
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 8
## Total graph size: 655
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 41
## Total graph size: 655
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 9
## Total graph size: 656
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 42
## Total graph size: 656
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 14
## Total graph size: 841
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 47
## Total graph size: 841
##
## Initializing model
##
## [1] "14 out of 36; 2024-03-04 13:28:44.773931"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 2
## Total graph size: 173
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 8
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 39
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 9
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 40
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 14
## Total graph size: 803
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 803
##
## Initializing model
##
## [1] "15 out of 36; 2024-03-04 13:33:27.13318"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 2
## Total graph size: 283
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 8
## Total graph size: 1035
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 61
## Total graph size: 1035
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 9
## Total graph size: 1036
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 62
## Total graph size: 1036
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 53
## Unobserved stochastic nodes: 14
## Total graph size: 1321
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 67
## Total graph size: 1321
##
## Initializing model
##
## [1] "16 out of 36; 2024-03-04 13:41:01.916646"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 2
## Total graph size: 188
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 8
## Total graph size: 684
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 42
## Total graph size: 684
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 9
## Total graph size: 685
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 43
## Total graph size: 685
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 14
## Total graph size: 875
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 48
## Total graph size: 875
##
## Initializing model
##
## [1] "17 out of 36; 2024-03-04 13:46:12.688335"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 2
## Total graph size: 173
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 8
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 39
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 9
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 40
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 14
## Total graph size: 803
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 803
##
## Initializing model
##
## [1] "18 out of 36; 2024-03-04 13:51:05.860827"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 2
## Total graph size: 78
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 8
## Total graph size: 266
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 20
## Total graph size: 266
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 9
## Total graph size: 267
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 21
## Total graph size: 267
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 14
## Total graph size: 347
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 26
## Total graph size: 347
##
## Initializing model
##
## [1] "19 out of 36; 2024-03-04 13:53:29.807313"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 38
## Unobserved stochastic nodes: 2
## Total graph size: 207
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 38
## Unobserved stochastic nodes: 8
## Total graph size: 756
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 46
## Total graph size: 756
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 38
## Unobserved stochastic nodes: 9
## Total graph size: 757
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 47
## Total graph size: 757
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 38
## Unobserved stochastic nodes: 14
## Total graph size: 967
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 52
## Total graph size: 967
##
## Initializing model
##
## [1] "20 out of 36; 2024-03-04 13:59:04.373675"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 23
## Unobserved stochastic nodes: 2
## Total graph size: 133
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 23
## Unobserved stochastic nodes: 8
## Total graph size: 471
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 31
## Total graph size: 471
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 23
## Unobserved stochastic nodes: 9
## Total graph size: 472
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 32
## Total graph size: 472
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 23
## Unobserved stochastic nodes: 14
## Total graph size: 607
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 37
## Total graph size: 607
##
## Initializing model
##
## [1] "21 out of 36; 2024-03-04 14:03:06.524762"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 2
## Total graph size: 163
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 8
## Total graph size: 589
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 37
## Total graph size: 589
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 9
## Total graph size: 590
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 38
## Total graph size: 590
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 14
## Total graph size: 755
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 43
## Total graph size: 755
##
## Initializing model
##
## [1] "22 out of 36; 2024-03-04 14:08:01.180482"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 2
## Total graph size: 76
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 8
## Total graph size: 266
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 20
## Total graph size: 266
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 9
## Total graph size: 267
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 21
## Total graph size: 267
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 12
## Unobserved stochastic nodes: 14
## Total graph size: 347
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 26
## Total graph size: 347
##
## Initializing model
##
## [1] "23 out of 36; 2024-03-04 14:10:29.52983"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 39
## Unobserved stochastic nodes: 2
## Total graph size: 213
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 39
## Unobserved stochastic nodes: 8
## Total graph size: 779
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 47
## Total graph size: 779
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 39
## Unobserved stochastic nodes: 9
## Total graph size: 780
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 48
## Total graph size: 780
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 39
## Unobserved stochastic nodes: 14
## Total graph size: 995
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 53
## Total graph size: 995
##
## Initializing model
##
## [1] "24 out of 36; 2024-03-04 14:16:15.90074"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 2
## Total graph size: 163
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 8
## Total graph size: 589
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 37
## Total graph size: 589
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 9
## Total graph size: 590
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 38
## Total graph size: 590
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 29
## Unobserved stochastic nodes: 14
## Total graph size: 755
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 43
## Total graph size: 755
##
## Initializing model
##
## [1] "25 out of 36; 2024-03-04 14:20:52.564105"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 2
## Total graph size: 198
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 8
## Total graph size: 722
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 44
## Total graph size: 722
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 9
## Total graph size: 723
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 723
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 14
## Total graph size: 923
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 50
## Total graph size: 923
##
## Initializing model
##
## [1] "26 out of 36; 2024-03-04 14:26:12.745967"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 13
## Unobserved stochastic nodes: 2
## Total graph size: 83
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 13
## Unobserved stochastic nodes: 8
## Total graph size: 285
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 21
## Total graph size: 285
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 13
## Unobserved stochastic nodes: 9
## Total graph size: 286
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 22
## Total graph size: 286
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 13
## Unobserved stochastic nodes: 14
## Total graph size: 371
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 27
## Total graph size: 371
##
## Initializing model
##
## [1] "27 out of 36; 2024-03-04 14:28:49.912955"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 2
## Total graph size: 173
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 8
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 39
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 9
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 40
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 14
## Total graph size: 803
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 803
##
## Initializing model
##
## [1] "28 out of 36; 2024-03-04 14:33:37.733173"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 2
## Total graph size: 188
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 8
## Total graph size: 678
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 42
## Total graph size: 678
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 9
## Total graph size: 679
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 43
## Total graph size: 679
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 34
## Unobserved stochastic nodes: 14
## Total graph size: 869
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 48
## Total graph size: 869
##
## Initializing model
##
## [1] "29 out of 36; 2024-03-04 14:38:49.530617"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 2
## Total graph size: 173
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 8
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 39
## Total graph size: 627
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 9
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 40
## Total graph size: 628
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 31
## Unobserved stochastic nodes: 14
## Total graph size: 803
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 803
##
## Initializing model
##
## [1] "30 out of 36; 2024-03-04 14:43:46.141406"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 18
## Unobserved stochastic nodes: 2
## Total graph size: 108
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 18
## Unobserved stochastic nodes: 8
## Total graph size: 380
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 26
## Total graph size: 380
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 18
## Unobserved stochastic nodes: 9
## Total graph size: 381
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 27
## Total graph size: 381
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 18
## Unobserved stochastic nodes: 14
## Total graph size: 491
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 32
## Total graph size: 491
##
## Initializing model
##
## [1] "31 out of 36; 2024-03-04 14:47:01.100631"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 2
## Total graph size: 183
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 8
## Total graph size: 665
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 41
## Total graph size: 665
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 9
## Total graph size: 666
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 42
## Total graph size: 666
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 33
## Unobserved stochastic nodes: 14
## Total graph size: 851
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 47
## Total graph size: 851
##
## Initializing model
##
## [1] "32 out of 36; 2024-03-04 14:52:11.166456"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 2
## Total graph size: 198
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 8
## Total graph size: 722
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 44
## Total graph size: 722
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 9
## Total graph size: 723
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 45
## Total graph size: 723
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 36
## Unobserved stochastic nodes: 14
## Total graph size: 923
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 50
## Total graph size: 923
##
## Initializing model
##
## [1] "33 out of 36; 2024-03-04 14:59:46.771349"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 35
## Unobserved stochastic nodes: 2
## Total graph size: 193
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 35
## Unobserved stochastic nodes: 8
## Total graph size: 703
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 43
## Total graph size: 703
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 35
## Unobserved stochastic nodes: 9
## Total graph size: 704
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 44
## Total graph size: 704
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 35
## Unobserved stochastic nodes: 14
## Total graph size: 899
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 49
## Total graph size: 899
##
## Initializing model
##
## [1] "34 out of 36; 2024-03-04 15:05:02.468894"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 8
## Unobserved stochastic nodes: 2
## Total graph size: 58
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 8
## Unobserved stochastic nodes: 8
## Total graph size: 190
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 16
## Total graph size: 190
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 8
## Unobserved stochastic nodes: 9
## Total graph size: 191
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 17
## Total graph size: 191
##
## Initializing model
##
## [1] "35 out of 36; 2024-03-04 15:05:59.789221"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 5
## Unobserved stochastic nodes: 2
## Total graph size: 43
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 5
## Unobserved stochastic nodes: 8
## Total graph size: 133
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 13
## Total graph size: 133
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 5
## Unobserved stochastic nodes: 9
## Total graph size: 134
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 14
## Total graph size: 134
##
## Initializing model
##
## [1] "36 out of 36; 2024-03-04 15:06:43.717946"
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 21
## Unobserved stochastic nodes: 2
## Total graph size: 123
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 21
## Unobserved stochastic nodes: 8
## Total graph size: 437
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 29
## Total graph size: 437
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 21
## Unobserved stochastic nodes: 9
## Total graph size: 438
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 30
## Total graph size: 438
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 21
## Unobserved stochastic nodes: 14
## Total graph size: 563
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 35
## Total graph size: 563
##
## Initializing model
## user system elapsed
## 9538.32 11.02 9551.05
rerunfun <- function(x, adapt=100000, iter=10000){
n <- nrow(x)
e <- simpleError("Fail")
# Fit four models: null and 3 cp models
# null model: 1 mean, 1 variance
fit0 <- tryCatch(
mcp(model=list(nsd~1),
prior=list(int_1="dnorm(0, 1000) T(0,)"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter),
error=function(e) e)
# 1 location, 2 variances, 1 change point
fit1 <- tryCatch(
mcp(model=list(nsd~1,
(1|year)~1 + sigma(1)),
prior=list(int_1="dnorm(0, 1000) T(0,)",
cp_1="dnorm(180, 20) T(0, 200)",
cp_1_sd="dnorm(0, 20) T(0,)",
int_2="int_1"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter, sample="both"),
error=function(e) e)
# 2 locations, 2 variances, 1 change point
fit2 <- tryCatch(
mcp(model=list(nsd~1,
(1|year)~1 + sigma(1)),
prior=list(int_1="dnorm(0, 1000) T(0,)",
int_2="dnorm(0, 1000) T(0,)",
cp_1="dnorm(180, 20) T(0, 200)",
cp_1_sd="dnorm(0, 20) T(0,)"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter, sample="both"),
error=function(e) e)
fitlist <- list(fit0=fit0, fit1=fit1, fit2=fit2)
if (nrow(x)>=12){ #the smallest that'll work on our data sets
# 3 locations, 3 variances, 2 change points
fit3 <- tryCatch(
mcp(model=list(nsd~1,
(1|year)~1 + sigma(1),
(1|year)~1),
prior=list(int_1="dnorm(0, 1000) T(0,)",
int_2="dnorm(0, 1000) T(0,)",
cp_1="dnorm(180, 20) T(0, 200)",
cp_2="dnorm(250, 20) T(200, 365)",
cp_1_sd="dnorm(0, 20) T(0,)",
cp_2_sd="dnorm(0, 20) T(0,)",
int_3="int_1"),
inits=inits0(chains=3),
data=x, par_x="doy", adapt=adapt, iter=iter, sample="both"),
error=function(e) e)
fitlist$fit3 <- fit3
}
return(fitlist)
}
Now the labor-intensive process of going through each fish individually to (1) select the change point model that best supports the data, and (b) classify tracks as migratory (or not), and (3) classify points as either spring, summer, or non-migratory
migplots <- function(sf.list=mcp_sf, i=1, mod=top){
name <- paste(names(mcp_sf)[[i]])
sex <- filter(fishids, FishID==as.numeric(names(mcp_sf)[[i]])) %>% pull(Sex)
tl <- filter(fishids, FishID==as.numeric(names(mcp_sf)[[i]])) %>% pull(TLmm)
p1 <- mcp_sf[[i]] %>%
ggplot() +
ggtitle(paste(name, sex, tl)) +
geom_tile(data=filter(lrw_df, !is.na(value)), aes(x=x, y=y),
fill='gray90') +
geom_sf(data=olb, color="light blue", fill=NA) +
geom_sf(data=mcp_sf_lines[[i]], color='gray70') +
geom_sf(data=slice(mcp_sf[[i]], which(t_==max(t_)|t_==min(t_))),
color=c("green", "red"), size=5) +
geom_sf(aes(color=doy, group=year)) +
scale_color_viridis_c(name="DOY") +
theme_void() +
coord_sf(xlim=pview[c(1,3)], ylim=pview[c(2,4)])
p2 <- mcp_sf[[i]] %>%
ggplot(aes(x=t_, y=nsd, color=factor(year(t_)))) +
geom_vline(xintercept=as.POSIXct(c("2009-01-01 00:00:00",
"2010-01-01 00:00:00",
"2011-01-01 00:00:00",
"2012-01-01 00:00:00")),
lty=2, color="dark gray") +
geom_point() + geom_line() +
scale_color_discrete(name="Year") +
coord_cartesian(xlim=as.POSIXct(c("2009-01-01 00:00:00",
"2012-01-01 00:00:00"))) +
ylab("Net Squared Displacement (meters)") + xlab("Time") +
theme_classic() +
theme(legend.position="top", axis.title.y=element_blank())
p2marg <- ggMarginal(p2, type="histogram", margin="y")
p3 <- plot_pars(mod, type="dens_overlay", ncol=5)
p4 <- pp_check(mod, type="loo_ribbon", nsamples=9000)
plotlist <- list(p1, p2marg, p3, p4)
plotout <- ggpubr::ggarrange(plotlist=plotlist)
return(plotout)
}
Create a function to check which MCP model performed the best and display results
topfun <- function(i){
fname <- names(mcp_sf)[i]
x <- mcp_models[[i]]
# check convergence, omit those not converged
maxRhat=sapply(x, function(x) fixef(x) %>% pull(Rhat) %>% max())
converged <- which(maxRhat<1.1)
# Compare models based on Pareto smoothed importance sampling in the `loo`
# package (Vehtari et al. 2017, 2019)
if (length(converged)>1){
loo <- lapply(x[converged], loo::loo)
loo_compare <- loo::loo_compare(loo)
# top converged model
topname <- rownames(loo_compare)[1]
top <- x[[topname]]
mcp_topmod_name[[i]] <- topname
return(list(name=fname, maxRhat=maxRhat, loo_compare=loo_compare,
topname=topname, top=top))
} else {
return(list(name=fname, maxRhat=maxRhat, loo_compare=NA,
topname=names(converged), top=x[[names(converged)]]))
}
}
checkfun <- function(i, top){
migplots(sf.list=mcp_sf, i=i, mod=top)
}
Create functions to extract season change dates from 1-cp and 2-cp MCP models
dates_1cp <- function(posteriors=mcp_models[[i]]$fit3$mcmc_post){
spread_draws(posteriors, cp_1, cp_1_year[year]) %>%
summarize_all(median) %>%
mutate(id=paste(names(mcp_sf)[[i]]),
year=paste(year),
cp_1=as_datetime(paste(year, round(cp_1 + cp_1_year, 0)),
format="%Y %j")) %>%
select(id, year, cp_1 )
}
dates_2cp <- function(posteriors=mcp_models[[i]]$fit3$mcmc_post){
spread_draws(posteriors, cp_1, cp_2, cp_1_year[year], cp_2_year[year]) %>%
summarize_all(median) %>%
mutate(id=paste(names(mcp_sf)[[i]]),
year=paste(year),
cp_1=as_datetime(paste(year, round(cp_1 + cp_1_year, 0)),
format="%Y %j"),
cp_2=as_datetime(paste(year, round(cp_2 + cp_2_year, 0)),
format="%Y %j")) %>%
select(id, year, cp_1, cp_2)
}
Include a function to plot results of best model
p2fun <- function(i, topname=mcp_modsel[[i]]){
name <- paste(names(mcp_sf)[[i]])
sex <- filter(fishids, FishID==as.numeric(names(mcp_sf)[[i]])) %>% pull(Sex)
tl <- filter(fishids, FishID==as.numeric(names(mcp_sf)[[i]])) %>% pull(TLmm)
p1 <- mcp_sf[[i]] %>%
ggplot() +
ggtitle(paste(name, sex, tl)) +
geom_tile(data=filter(lrw_df, !is.na(value)), aes(x=x, y=y),
fill='gray90') +
geom_sf(data=olb, color="light blue", fill=NA) +
geom_sf(data=mcp_sf_lines[[i]], color='gray70') +
geom_sf(data=slice(mcp_sf[[i]], which(t_==max(t_)|t_==min(t_))),
color=c("green", "red"), size=5) +
geom_sf(aes(color=doy, group=year)) +
scale_color_viridis_c(name="DOY") +
theme_void() +
coord_sf(xlim=pview[c(1,3)], ylim=pview[c(2,4)])
p2 <- mcp_sf2[[i]] %>%
ggplot(aes(x=t_, y=nsd)) +
geom_vline(xintercept=as.POSIXct(c("2009-01-01 00:00:00",
"2010-01-01 00:00:00",
"2011-01-01 00:00:00",
"2012-01-01 00:00:00")),
lty=2, color="dark gray") +
geom_line(aes(group=factor(year(t_)))) +
geom_point(aes(fill=factor(season)), color="grey50", shape=21, size=3) +
scale_fill_grey(name="Season", na.value="white") +
#scale_color_discrete(name="Year") +
coord_cartesian(xlim=as.POSIXct(c("2009-01-01 00:00:00",
"2012-01-01 00:00:00"))) +
ylab("Net Squared Displacement (meters)") + xlab("Time") +
theme_classic() +
theme(legend.position="none", axis.title.y=element_blank())
p2marg <- ggMarginal(p2, type="histogram", margin="y")
patchwork::plot_layout(p1 + p2marg +
patchwork::plot_annotation(caption=topname))
#ggpubr::ggarrange(plotlist=list(p1, p2marg))
}
Some list objects to hold resutls
mcp_sf2 <- list()
mcp_modsel <- list()
mcp_topmod <- list()
mcp_topmod_name <- list()
mcp_plot <- list()
i=1
(mcp_modsel[[i]] <- topfun(i=i))
## $name
## [1] "12"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000009 1.085988 1.004251 1.001216
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit3 -1.0 1.1
## fit1 -5.0 10.7
## fit0 -13.4 8.6
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 152.86 1.4e+02 169.1 1 8698
## cp_1_sd 12.58 1.9e-03 34.0 1 5169
## int_1 0.67 1.6e-04 1.4 1 50756
## int_2 10.01 8.1e+00 11.9 1 101700
## sigma_1 1.42 6.6e-01 2.3 1 20375
## sigma_2 3.37 2.1e+00 4.9 1 48532
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
mcp_topmod[[i]] <- mcp_modsel[[i]]$top
(mcp_plot[[i]] <- checkfun(i=i, mcp_topmod[[i]]))
paste("n =", nrow(mcp_sf[[i]]))
## [1] "n = 24"
mcp_sf2[[i]] <- left_join(mcp_sf[[i]],
dates_1cp(posteriors=mcp_topmod[[i]]$mcmc_post)) %>%
mutate(season=1*(t_>cp_1))
# dates_2cp(posteriors=mcp_topmod[[i]]$mcmc_post)) %>%
# mutate(season=ifelse(t_>cp_2, NA, 1*(t_>cp_1)))
names(mcp_sf2)[i] <- names(mcp_sf)[i]
(p2 <- p2fun(i, topname=mcp_modsel[[i]]$topname))
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "14"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000065 1.009608 1.000801 1.000799
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -7.7 16.2
## fit1 -42.5 20.8
## fit0 -49.7 22.1
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 152.8 148.540 157.0 1 58044
## cp_1_sd 18.0 5.179 36.1 1 11607
## cp_2 280.5 272.591 289.5 1 5572
## cp_2_sd 15.3 0.015 35.4 1 4456
## int_1 2.6 0.407 4.8 1 146451
## int_2 34.9 33.120 36.7 1 148790
## int_3 2.6 0.407 4.8 1 146451
## sigma_1 4.2 2.614 6.2 1 55262
## sigma_2 5.7 4.555 7.1 1 77437
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 55"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "15"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000183 1.001504 1.000238 1.000378
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -1.5 2.1
## fit1 -4.1 2.8
## fit0 -47.9 10.9
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 179.4 1.6e+02 192.5 1 4157
## cp_1_sd 27.1 6.0e+00 50.0 1 8709
## cp_2 230.3 2.0e+02 263.3 1 5887
## cp_2_sd 21.1 5.6e-03 43.7 1 7705
## int_1 1.0 4.3e-01 1.6 1 140419
## int_2 49.5 1.8e+01 79.9 1 8137
## int_3 1.0 4.3e-01 1.6 1 140419
## sigma_1 1.2 7.8e-01 1.7 1 57132
## sigma_2 36.1 2.3e+01 50.8 1 11188
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 36"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
This one doesn’t work out of the box due to convergence issues. Run again with more iterations to see if longer chains allow convergence.
## $name
## [1] "16"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000180 1.000948 1.000617 1.001952
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -0.1 0.2
## fit1 -3.2 1.9
## fit0 -49.7 12.8
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 142.35 1.3e+02 154.53 1 9221
## cp_1_sd 14.98 3.7e-03 35.32 1 6934
## cp_2 250.58 2.1e+02 285.21 1 627
## cp_2_sd 15.51 8.2e-04 38.24 1 4513
## int_1 0.14 1.3e-04 0.28 1 133068
## int_2 69.28 2.5e+01 113.04 1 147212
## int_3 0.14 1.3e-04 0.28 1 133068
## sigma_1 0.26 1.5e-01 0.41 1 43317
## sigma_2 68.36 4.2e+01 99.12 1 59355
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 20"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "19"
##
## $maxRhat
## fit0 fit1 fit2
## 1.000498 1.007533 1.006373
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit1 -2.6 1.9
## fit0 -3.3 1.8
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 155 1.3e+02 193 1 699
## cp_1_sd 15 1.8e-04 39 1 10547
## int_1 45 1.2e-07 233 1 488
## int_2 328 2.4e-01 838 1 2997
## sigma_1 47 1.1e-04 208 1 425
## sigma_2 131 2.6e+00 246 1 20095
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 7"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "20"
##
## $maxRhat
## fit0 fit1 fit2
## 1.000166 1.001682 1.000963
##
## $loo_compare
## elpd_diff se_diff
## fit1 0.0 0.0
## fit2 -0.2 0.0
## fit0 -0.2 0.0
##
## $topname
## [1] "fit1"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 172.3 1.4e+02 200 1 648
## cp_1_sd 16.1 1.1e-03 39 1 6822
## int_1 5.3 1.7e-04 12 1 18704
## int_2 5.3 1.7e-04 12 1 18704
## sigma_1 8.8 1.2e+00 15 1 7253
## sigma_2 7.1 1.0e-04 17 1 21915
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 5"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
Note: the stationary model was equivalent to migration models by cross validation analyis.
## $name
## [1] "21"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000052 1.000275 1.000723 1.048086
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit1 -2.5 2.7
## fit3 -3.4 1.8
## fit0 -9.1 6.3
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 136.7 115.806 172 1 5827
## cp_1_sd 23.2 0.018 46 1 8104
## int_1 21.4 0.165 40 1 18533
## int_2 42.6 39.258 46 1 137396
## sigma_1 20.1 10.664 31 1 53826
## sigma_2 7.6 5.379 10 1 45541
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 27"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "22"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000011 1.000123 1.005934 1.034348
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit1 -4.9 4.1
## fit2 -5.6 3.1
## fit0 -5.6 5.0
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 180 1.6e+02 200 1 5255
## cp_1_sd 17 1.7e-03 41 1 6107
## cp_2 216 2.0e+02 253 1 858
## cp_2_sd 16 3.6e-04 40 1 6860
## int_1 46 5.9e-03 90 1 1225
## int_2 309 1.3e+01 415 1 900
## int_3 46 5.9e-03 90 1 1225
## sigma_1 73 3.2e+01 143 1 2339
## sigma_2 67 2.6e+01 123 1 5894
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 15"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "23"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.00002 1.00041 1.00049 21.93941
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit1 -0.8 1.5
## fit0 -38.1 8.4
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 158.00 133.833 182.76 1 6761
## cp_1_sd 43.05 22.798 64.55 1 28477
## int_1 0.20 0.120 0.28 1 153518
## int_2 9.68 0.085 18.46 1 142311
## sigma_1 0.11 0.059 0.18 1 50387
## sigma_2 13.34 7.642 20.10 1 62714
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 15"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
Note: there is actually no seasonal pattern observed here, just two outliers in the third year. Classification based on CP interval result in all spring locations in 2009 and 2010, and all summer locations in 2011. this is not plausible given the spread in dates. Classify this one as stationary.
## $name
## [1] "25"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000066 1.001265 1.001886 1.008441
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit1 -18.3 13.2
## fit2 -19.0 13.3
## fit0 -70.2 13.0
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 182 174.36 191.3 1 7443
## cp_1_sd 13 0.51 30.6 1 5618
## cp_2 270 264.37 280.0 1 1112
## cp_2_sd 17 0.34 37.6 1 1613
## int_1 30 26.24 34.2 1 145526
## int_2 46 45.16 46.8 1 138239
## int_3 30 26.24 34.2 1 145526
## sigma_1 76 54.58 99.5 1 74403
## sigma_2 2 1.41 2.6 1 40069
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 43"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "26"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000016 1.003543 1.000384 1.002497
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit3 -6.2 9.5
## fit1 -29.0 9.2
## fit0 -45.3 10.0
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 176.5 165.35 186.9 1 5277
## cp_1_sd 39.2 21.88 59.3 1 36198
## int_1 3.6 2.96 4.3 1 151032
## int_2 27.0 23.52 30.5 1 149111
## sigma_1 1.4 0.96 2.0 1 54963
## sigma_2 8.7 6.35 11.4 1 65628
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 43"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "27"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000004 1.001671 1.000147 1.008443
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -33.6 18.2
## fit1 -45.7 27.4
## fit0 -156.3 25.7
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 152.24 1.5e+02 156.51 1 12248
## cp_1_sd 15.52 3.5e+00 32.74 1 6402
## cp_2 287.89 2.7e+02 305.95 1 1653
## cp_2_sd 13.03 2.8e-04 33.08 1 4489
## int_1 0.20 8.2e-05 0.40 1 133183
## int_2 312.49 3.1e+02 316.00 1 149712
## int_3 0.20 8.2e-05 0.40 1 133183
## sigma_1 0.41 2.4e-01 0.63 1 43755
## sigma_2 11.38 9.0e+00 14.01 1 77356
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 53"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "28"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000061 1.000597 1.012495 1.001111
##
## $loo_compare
## elpd_diff se_diff
## fit1 0.0 0.0
## fit3 -5.7 4.3
## fit2 -6.3 5.3
## fit0 -21.6 7.4
##
## $topname
## [1] "fit1"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 183.3 1.7e+02 196 1 11322
## cp_1_sd 12.6 5.2e-04 33 1 6143
## int_1 77.6 7.4e+01 81 1 105641
## int_2 77.6 7.4e+01 81 1 105641
## sigma_1 47.8 3.1e+01 67 1 66876
## sigma_2 8.7 6.3e+00 11 1 31869
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 33"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "29"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000023 1.009537 1.003667 1.015956
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit3 -1.0 0.8
## fit1 -2.6 3.3
## fit0 -102.3 10.0
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 118.18 109.69 123.34 1 2566
## cp_1_sd 11.40 0.58 29.58 1 4097
## int_1 22.37 10.34 34.35 1 69422
## int_2 0.26 0.20 0.32 1 145458
## sigma_1 12.88 6.86 20.25 1 54807
## sigma_2 0.16 0.12 0.20 1 69918
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 31"
This looks like a stationary home range with occasional non-repeated forays, but the single change point model for NSD variance performed the best.
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "30"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000042 1.000672 1.000357 1.000091
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -29.2 8.8
## fit1 -44.3 9.5
## fit0 -100.0 9.3
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 182.4 178.95 185.6 1 31312
## cp_1_sd 9.8 0.59 25.3 1 4146
## cp_2 243.8 236.36 251.2 1 33256
## cp_2_sd 19.2 4.13 39.7 1 17777
## int_1 1.3 0.76 1.9 1 148410
## int_2 47.0 43.38 50.4 1 150000
## int_3 1.3 0.76 1.9 1 148410
## sigma_1 1.4 1.05 1.9 1 69168
## sigma_2 7.6 5.61 9.9 1 71359
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 53"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "13"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000094 1.000143 1.000462 1.003203
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -1.4 1.5
## fit1 -30.9 5.5
## fit0 -42.6 11.3
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 160 1.5e+02 173 1 11677
## cp_1_sd 12 9.7e-05 30 1 7103
## cp_2 262 2.4e+02 288 1 2148
## cp_2_sd 25 2.9e-01 47 1 4709
## int_1 21 4.0e+00 38 1 7322
## int_2 190 1.8e+02 201 1 12532
## int_3 21 4.0e+00 38 1 7322
## sigma_1 23 1.3e+01 36 1 10944
## sigma_2 23 1.4e+01 32 1 7705
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 34"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "17"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000024 1.380727 97.524876 1.004408
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit0 -19.0 9.7
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 130 1.1e+02 155 1 5554
## cp_1_sd 17 8.0e-05 42 1 4558
## cp_2 247 2.3e+02 260 1 1892
## cp_2_sd 36 1.7e+01 57 1 5535
## int_1 62 1.1e+01 110 1 60014
## int_2 316 2.9e+02 337 1 142728
## int_3 62 1.1e+01 110 1 60014
## sigma_1 102 9.8e+00 222 1 29210
## sigma_2 53 3.9e+01 69 1 54506
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 31"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "18"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000035 1.000593 1.002727 22.520377
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit1 -6.0 3.6
## fit0 -17.3 6.1
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 192 1.8e+02 200 1 13292
## cp_1_sd 16 8.1e-03 38 1 7471
## int_1 320 3.0e+02 335 1 128072
## int_2 39 1.6e-03 94 1 17099
## sigma_1 22 1.1e+01 36 1 27097
## sigma_2 49 1.0e+01 127 1 11856
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 12"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "34"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000019 1.001548 1.006725 1.004624
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -0.9 0.7
## fit1 -5.5 4.5
## fit0 -63.1 9.4
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 174 1.6e+02 189 1 2908
## cp_1_sd 49 3.1e+01 69 1 44689
## cp_2 291 2.7e+02 311 1 1597
## cp_2_sd 15 3.3e-03 38 1 3899
## int_1 102 4.5e-01 220 1 3346
## int_2 325 3.2e+02 330 1 2936
## int_3 102 4.5e-01 220 1 3346
## sigma_1 112 5.4e+01 180 1 40332
## sigma_2 12 8.5e+00 17 1 1982
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 38"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "35"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000015 6.525329 1.000383 4.427246
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit0 -23.2 6.6
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 161.4 137.6 184 1 3221
## cp_1_sd 44.9 26.6 65 1 53784
## int_1 338.8 333.1 345 1 150971
## int_2 165.5 107.2 222 1 150000
## sigma_1 7.6 3.8 13 1 30526
## sigma_2 109.8 72.8 153 1 63035
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 23"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "36"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000034 1.000228 1.001134 1.001501
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -46.0 15.6
## fit0 -50.8 7.1
## fit1 -58.4 11.4
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 188.4 1.8e+02 200.0 1 2534
## cp_1_sd 20.2 5.9e+00 39.3 1 5693
## cp_2 279.4 2.6e+02 292.6 1 10951
## cp_2_sd 17.2 1.1e-02 40.6 1 5856
## int_1 1.6 1.5e-04 3.8 1 71937
## int_2 45.7 4.5e+01 46.3 1 147756
## int_3 1.6 1.5e-04 3.8 1 71937
## sigma_1 13.5 7.5e+00 20.2 1 52561
## sigma_2 1.3 8.9e-01 1.9 1 45478
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 29"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "37"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000038 1.437308 1.015431 4.032248
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit0 -21.2 11.2
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 137.797 1.1e+02 164.797 1 3574
## cp_1_sd 37.645 1.6e+01 60.558 1 12682
## int_1 0.035 3.2e-03 0.059 1 5175
## int_2 26.912 1.2e+01 41.634 1 151517
## sigma_1 0.023 1.7e-03 0.072 1 2896
## sigma_2 21.791 1.3e+01 32.695 1 54854
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 12"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "38"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000011 10.665234 2.525462 1.019649
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit0 -56.5 16.7
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 144.18 1.3e+02 163.1 1 1684
## cp_1_sd 14.60 6.8e-05 37.5 1 2672
## cp_2 279.25 2.6e+02 293.8 1 9774
## cp_2_sd 17.54 2.1e-03 41.7 1 5135
## int_1 0.71 2.6e-04 1.5 1 133733
## int_2 245.59 2.2e+02 272.7 1 152124
## int_3 0.71 2.6e-04 1.5 1 133733
## sigma_1 1.69 9.8e-01 2.6 1 47122
## sigma_2 70.34 5.2e+01 90.6 1 63338
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 39"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "39"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000049 1.000699 1.000122 1.001045
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -0.9 2.9
## fit1 -14.0 3.8
## fit0 -47.3 9.4
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 169.4 1.5e+02 186.8 1 36930
## cp_1_sd 12.0 3.9e-04 31.7 1 7720
## cp_2 268.5 2.4e+02 289.2 1 7288
## cp_2_sd 17.5 3.0e-03 40.5 1 6623
## int_1 1.5 2.1e-01 2.7 1 140639
## int_2 138.9 1.1e+02 170.6 1 38418
## int_3 1.5 2.1e-01 2.7 1 140639
## sigma_1 2.3 1.4e+00 3.4 1 48313
## sigma_2 56.0 3.7e+01 78.6 1 49946
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 29"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "40"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000060 1.000081 1.000092 1.000332
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -1.4 2.5
## fit1 -5.1 3.7
## fit0 -122.8 11.8
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 192.23 1.8e+02 200.00 1 9363
## cp_1_sd 43.92 2.5e+01 64.69 1 44529
## cp_2 257.94 2.2e+02 287.01 1 882
## cp_2_sd 21.09 1.7e-03 47.00 1 2106
## int_1 0.31 2.1e-01 0.43 1 4436
## int_2 67.62 3.9e+01 96.03 1 101273
## int_3 0.31 2.1e-01 0.43 1 4436
## sigma_1 0.26 1.5e-01 0.35 1 2052
## sigma_2 38.93 2.3e+01 57.62 1 43771
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 36"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "41"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000043 1.042543 1.001814 1.002549
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -2.3 2.6
## fit1 -2.5 2.3
## fit0 -17.8 4.7
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 161.140 1.4e+02 187.787 1 1521
## cp_1_sd 22.173 7.5e-03 44.024 1 2829
## cp_2 265.510 2.3e+02 289.963 1 11128
## cp_2_sd 17.432 4.9e-03 41.189 1 7505
## int_1 0.020 3.0e-03 0.038 1 19971
## int_2 0.510 2.0e-01 0.757 1 10500
## int_3 0.020 3.0e-03 0.038 1 19971
## sigma_1 0.026 9.5e-03 0.043 1 8149
## sigma_2 0.189 5.3e-02 0.396 1 6746
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 13"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "42"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000015 11.534055 1.724849 2.532344
##
## $loo_compare
## [1] NA
##
## $topname
## [1] "fit0"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## int_1 133 98 169 1 150000
## sigma_1 100 76 126 1 72442
## [1] "n = 31"
i=27
#only one model (the null) converged, but change points seem obvious
sapply(mcp_models[[i]], function(x) fixef(x) %>% pull(Rhat) %>% max())
## fit0 fit1 fit2 fit3
## 1.000015 11.534055 1.724849 2.532344
# first observation in 2009 seems inconsistent with rest of data\
# omit first year (single observation) and rerun
mcp_models[[i]] <- rerunfun(x=mcp_sf[[i]] %>% filter(year(t_)>2009),
adapt=200000,
iter=50000)
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 30
## Unobserved stochastic nodes: 2
## Total graph size: 168
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 30
## Unobserved stochastic nodes: 7
## Total graph size: 605
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 37
## Total graph size: 605
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 30
## Unobserved stochastic nodes: 8
## Total graph size: 606
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 38
## Total graph size: 606
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 30
## Unobserved stochastic nodes: 12
## Total graph size: 773
##
## Initializing model
##
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 0
## Unobserved stochastic nodes: 42
## Total graph size: 773
##
## Initializing model
## $name
## [1] "42"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000114 1.001031 1.588917 3.083044
##
## $loo_compare
## elpd_diff se_diff
## fit1 0.0 0.0
## fit0 -14.8 4.3
##
## $topname
## [1] "fit1"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 170 1.6e+02 185 1 23710
## cp_1_sd 12 4.0e-04 33 1 9202
## int_1 195 1.8e+02 209 1 102627
## int_2 195 1.8e+02 209 1 102627
## sigma_1 168 1.1e+02 230 1 65576
## sigma_2 29 2.0e+01 41 1 49971
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 31"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "43"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000058 1.000066 1.000118 1.000401
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -1.3 1.5
## fit1 -9.8 3.9
## fit0 -158.0 28.5
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 185.009 168.152 199.999 1 7404
## cp_1_sd 41.685 23.653 61.900 1 60554
## cp_2 262.033 242.508 284.948 1 13042
## cp_2_sd 13.886 0.001 35.925 1 8520
## int_1 0.041 0.036 0.046 1 147758
## int_2 221.819 147.073 295.738 1 121546
## int_3 0.041 0.036 0.046 1 147758
## sigma_1 0.011 0.007 0.015 1 78723
## sigma_2 141.719 95.929 193.881 1 56013
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 34"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
This fish was manually classified as “stationary” due to lack of fit. The CPM did not distinguish the change points that are evident to the naked eye in 2010, classifying all observations in this year as “summer”, likely an artifact related to the lack of migration in 2011.
## $name
## [1] "44"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000049 1.001185 1.323040 1.087837
##
## $loo_compare
## elpd_diff se_diff
## fit0 0.0 0.0
## fit3 -0.4 2.2
## fit1 -1.0 1.2
##
## $topname
## [1] "fit0"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## int_1 0.31 0.21 0.41 1 150000
## sigma_1 0.29 0.22 0.36 1 72026
## [1] "n = 31"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "46"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000121 1.255379 1.014443 1.001405
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit3 -1.1 14.2
## fit0 -58.0 17.8
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 1.8e+02 1.4e+02 199.999 1 216
## cp_1_sd 3.8e+01 2.4e-02 64.413 1 292
## int_1 8.8e-03 2.9e-06 0.019 1 51558
## int_2 1.2e+02 7.1e+01 167.243 1 12688
## sigma_1 1.7e-02 8.2e-03 0.029 1 27689
## sigma_2 7.4e+01 4.3e+01 109.426 1 23245
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 18"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "47"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000063 8.084076 5.660379 7.175520
##
## $loo_compare
## [1] NA
##
## $topname
## [1] "fit0"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## int_1 31 3.9 56 1 148627
## sigma_1 82 62.9 103 1 76938
## [1] "n = 33"
Only the null model converged for this one, so use it.
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "49"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000053 1.001871 1.000515 1.003002
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -13.0 10.8
## fit1 -15.9 10.8
## fit0 -85.1 6.9
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 1.4e+02 1.1e+02 1.6e+02 1 897
## cp_1_sd 3.6e+01 1.6e+01 5.8e+01 1 4919
## cp_2 2.7e+02 2.5e+02 2.9e+02 1 11751
## cp_2_sd 1.7e+01 4.3e-03 4.0e+01 1 7327
## int_1 5.0e-03 6.2e-08 1.2e-02 1 131042
## int_2 3.8e-02 3.6e-02 4.0e-02 1 149517
## int_3 5.0e-03 6.2e-08 1.2e-02 1 131042
## sigma_1 3.2e-01 2.1e-01 4.3e-01 1 75369
## sigma_2 5.9e-03 4.3e-03 7.6e-03 1 63738
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 36"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "50"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000007 1.090981 1.000653 1.001254
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit2 -11.8 8.9
## fit0 -31.2 6.4
## fit1 -36.3 9.8
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 151.2 1.3e+02 168.0 1 12090
## cp_1_sd 13.1 1.8e-06 35.5 1 5230
## cp_2 278.1 2.6e+02 292.5 1 11837
## cp_2_sd 16.8 3.1e-03 40.4 1 5624
## int_1 23.8 2.2e+01 25.2 1 118564
## int_2 52.7 4.9e+01 56.4 1 149163
## int_3 23.8 2.2e+01 25.2 1 118564
## sigma_1 1.9 9.4e-01 3.3 1 28858
## sigma_2 9.5 7.0e+00 12.4 1 58325
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 35"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "32"
##
## $maxRhat
## fit0 fit1 fit2
## 1.000081 1.000877 1.154574
##
## $loo_compare
## elpd_diff se_diff
## fit0 0.0 0.0
## fit1 -0.3 0.5
##
## $topname
## [1] "fit0"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## int_1 38 14 63 1 148989
## sigma_1 34 19 51 1 53127
## [1] "n = 8"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "45"
##
## $maxRhat
## fit0 fit1 fit2
## 1.000102 1.000527 1.000450
##
## $loo_compare
## elpd_diff se_diff
## fit2 0.0 0.0
## fit1 -3.7 1.1
## fit0 -3.7 1.7
##
## $topname
## [1] "fit2"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 174.4 1.5e+02 200 1 75156
## cp_1_sd 15.8 1.6e-03 39 1 8076
## int_1 31.8 1.2e+01 51 1 148677
## int_2 3.8 9.7e-05 15 1 15185
## sigma_1 15.2 4.9e+00 30 1 35900
## sigma_2 6.2 2.9e-01 22 1 8956
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year
## [1] "n = 5"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
## $name
## [1] "48"
##
## $maxRhat
## fit0 fit1 fit2 fit3
## 1.000115 1.139809 1.417757 1.000714
##
## $loo_compare
## elpd_diff se_diff
## fit3 0.0 0.0
## fit0 -21.9 7.1
##
## $topname
## [1] "fit3"
##
## $top
## Family: gaussian(link = 'identity')
## Iterations: 150000 from 3 chains.
## Segments:
## 1: nsd ~ 1
## 2: nsd ~ (1 | year) ~ 1 + sigma(1)
## 3: nsd ~ (1 | year) ~ 1
##
## Population-level parameters:
## name mean lower upper Rhat n.eff
## cp_1 149 1.3e+02 174 1 3908
## cp_1_sd 21 1.8e-02 43 1 5409
## cp_2 269 2.4e+02 294 1 14312
## cp_2_sd 17 5.2e-04 41 1 7536
## int_1 31 6.6e-03 63 1 88937
## int_2 308 2.9e+02 329 1 135777
## int_3 31 6.6e-03 63 1 88937
## sigma_1 61 2.6e+01 111 1 30038
## sigma_2 37 2.3e+01 54 1 39019
##
## Use `ranef(fit)` to summarise the varying effect(s): cp_1_year, cp_2_year
## [1] "n = 21"
## $ncol
##
## $nrow
## NULL
##
## $byrow
## NULL
##
## $widths
## NULL
##
## $heights
## NULL
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $axes
## NULL
##
## $axis_titles
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
Collate and save the results for further home range analysis.
mcp_sf2_tab <- bind_rows(mcp_sf2)
names(mcp_topmod) <- names(mcp_sf)
save(mcp_sf2_tab, mcp_sf2, mcp_topmod, file="mcp_out.RData")
testjags()
## You are using R version 4.3.1 (2023-06-16 ucrt) on a windows machine,
## with the RTerm GUI
## JAGS version 4.3.1 found successfully using the command 'C:/Program
## Files/JAGS/JAGS-4.3.1/x64/bin/jags-terminal.exe'
## The rjags package is installed
sessionInfo()
## R version 4.3.1 (2023-06-16 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
##
## Matrix products: default
##
##
## locale:
## [1] LC_COLLATE=English_United States.utf8
## [2] LC_CTYPE=English_United States.utf8
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.utf8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] mcp_0.3.3 runjags_2.2.2-1.1 amt_0.2.1.0
## [4] raster_3.6-26 sp_2.1-2 sf_1.0-14
## [7] readxl_1.4.3 kableExtra_1.3.4.9000 ggExtra_0.10.1
## [10] tidybayes_3.0.6 lubridate_1.9.3 forcats_1.0.0
## [13] stringr_1.5.1 dplyr_1.1.2 purrr_1.0.2
## [16] readr_2.1.4 tidyr_1.3.0 tibble_3.2.1
## [19] ggplot2_3.4.4 tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] Rdpack_2.6 DBI_1.2.1 rlang_1.1.1
## [4] magrittr_2.0.3 matrixStats_1.2.0 e1071_1.7-13
## [7] compiler_4.3.1 loo_2.6.0 reshape2_1.4.4
## [10] systemfonts_1.0.5 vctrs_0.6.3 rvest_1.0.3
## [13] crayon_1.5.2 pkgconfig_2.0.3 arrayhelpers_1.1-0
## [16] fastmap_1.1.1 backports_1.4.1 ellipsis_0.3.2
## [19] labeling_0.4.3 utf8_1.2.3 promises_1.2.1
## [22] rmarkdown_2.25 tzdb_0.4.0 bit_4.0.5
## [25] xfun_0.39 cachem_1.0.8 jsonlite_1.8.8
## [28] highr_0.10 later_1.3.2 terra_1.7-65
## [31] broom_1.0.5 parallel_4.3.1 R6_2.5.1
## [34] bslib_0.6.1 stringi_1.7.12 car_3.1-2
## [37] rjags_4-15 jquerylib_0.1.4 cellranger_1.1.0
## [40] Rcpp_1.0.11 knitr_1.45 bayesplot_1.10.0
## [43] httpuv_1.6.13 Matrix_1.6-0 splines_4.3.1
## [46] timechange_0.2.0 tidyselect_1.2.0 rstudioapi_0.15.0
## [49] abind_1.4-5 yaml_2.3.8 ctmm_1.2.0
## [52] codetools_0.2-19 miniUI_0.1.1.1 plyr_1.8.8
## [55] lattice_0.22-5 shiny_1.8.0 withr_3.0.0
## [58] posterior_1.5.0 coda_0.19-4 evaluate_0.23
## [61] survival_3.5-7 units_0.8-4 proxy_0.4-27
## [64] ggdist_3.3.1 xml2_1.3.6 ggpubr_0.6.0
## [67] pillar_1.9.0 carData_3.0-5 tensorA_0.36.2.1
## [70] KernSmooth_2.23-22 checkmate_2.3.1 distributional_0.3.2
## [73] generics_0.1.3 vroom_1.6.3 hms_1.1.3
## [76] munsell_0.5.0 scales_1.3.0 xtable_1.8-4
## [79] class_7.3-22 glue_1.6.2 tools_4.3.1
## [82] robustbase_0.99-1 RSpectra_0.16-1 ggsignif_0.6.4
## [85] webshot_0.5.5 cowplot_1.1.2 grid_4.3.1
## [88] rbibutils_2.2.16 colorspace_2.1-0 patchwork_1.2.0
## [91] cli_3.6.1 Gmedian_1.2.7 fansi_1.0.4
## [94] svUnit_1.0.6 viridisLite_0.4.2 svglite_2.1.3
## [97] DEoptimR_1.1-3 gtable_0.3.4 rstatix_0.7.2
## [100] sass_0.4.8 digest_0.6.34 classInt_0.4-10
## [103] farver_2.1.1 htmltools_0.5.7 lifecycle_1.0.4
## [106] httr_1.4.7 mime_0.12 bit64_4.0.5